import * as types from '../mutation-types'

const state = {
  theme: 'dark',
  themeClass: 'theme-dark'
}

const getters = {
  theme (state) {
    return state.theme
  },
  themeClass () {
    return state.themeClass
  }
}

const actions = {
  getTheme ({commit}) {
    commit([types.GET_THEME])
  }
}

const mutations = {
  GET_THEME (state) {
    if (state.theme === 'dark') {
      state.theme = 'dark'
      state.themeClass = 'theme-dark'
    } else if (state.theme === 'light') {
      state.theme = 'light'
      state.themeClass = 'theme-light'
    } else if (state.theme === 'primary') {
      state.theme = 'primary'
      state.themeClass = 'theme-primary'
    }
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
